﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LevelHeart4Part : MonoBehaviour
{
    public GameLevelItem gameLevelItem;
    public RectTransform top;
    public RectTransform bottom;
    public RectTransform left;
    public RectTransform right;
    private bool isFinished;

    private void Start()
    {
        CheckResult();
    }
    public void CheckResult()
    {
        if (isFinished) return;
        bool result = true;
        if (top.anchoredPosition.y > 1)
            result = false;
        if (bottom.anchoredPosition.y < -1)
            result = false;
        if (left.anchoredPosition.x < -1)
            result = false;
        if (right.anchoredPosition.x > 1)
            result = false;

        if (result)
        {
            isFinished = true;
            gameLevelItem.TriggerResult(true);
        }
        else
        {
            Invoke("CheckResult", 0.5f);
        }


    }

}
